class_numbers = []
total_classes = 5

for i in range(total_classes):
    while True:
        try:
            class_size = int(input(f"请输入第 {i + 1} 个班级的人数: "))
            if class_size >= 0:
                class_numbers.append(class_size)
                break
            else:
                print("班级人数不能为负数，请重新输入。")
        except ValueError:
            print("输入无效，请输入一个有效的整数。")

total_students = sum(class_numbers)
print(f"所有班级的总人数是: {total_students}")